﻿using System;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections.Generic;
using System.Collections.Specialized;

using HtmlAgilityPack;

namespace WCrawlerLib
{
    public interface  IWebSession
    {
        #region Properties
            /// <summary>
            /// HtmlDocument
            /// </summary>
            HtmlAgilityPack.HtmlDocument HtmlDoc { get; set; }

            /// <summary>
            /// System.Net.CookieCollection. Provides a collection container for instances of Cookie class 
            /// </summary>
            HtmlAgilityPack.HtmlWeb HtmlWeb { get; set; }

            /// <summary>
            /// System.Net.CookieCollection. Provides a collection container for instances of Cookie class 
            /// </summary>
            CookieCollection Cookies { get; set; }

            HttpWebRequest Request { get; set; }

            HttpWebResponse Response { get; set; }
        #endregion

        #region Methods
            /// <summary>
            /// Makes a HTTP GET request to the given URL
            /// </summary>
            HtmlAgilityPack.HtmlDocument Get(string url);

            /// <summary>
            /// Makes a HTTP POST request to the given URL
            /// </summary>
            HtmlAgilityPack.HtmlDocument Post(string url);

            HtmlAgilityPack.HtmlDocument Post(string url, bool allowAutoRedirect);

            /// <summary>
            /// Creates the HtmlWeb object and initializes all event handlers. 
            /// </summary>
            HtmlWeb CreateWebRequestObject();

            /// <summary>
            /// Event handler for HtmlWeb.PreRequestHandler. Occurs before an HTTP request is executed.
            /// </summary>
            bool OnPreRequest(HttpWebRequest request);

            /// <summary>
            /// Event handler for HtmlWeb.PreHandleDocumentHandler. Occurs before a HTML document is handled
            /// </summary>
            void OnPreHandleDocument(HtmlAgilityPack.HtmlDocument document);

            /// <summary>
            /// Add cookies to the request object
            /// </summary>
            void AddCookiesTo();

            /// <summary>
            /// Assembles the Post data and attaches to the request object
            /// </summary>
            void AddPostDataTo();

            /// <summary>
            /// Saves cookies from the response object to the local CookieCollection object
            /// </summary>
            void SaveCookiesFrom();

            /// <summary>
            /// Saves cookies from the response object to the local CookieCollection object
            /// </summary>
            void SaveCookiesFrom(CookieCollection cookieCollect);

            /// <summary>
            /// Event handler for HtmlWeb.PostResponseHandler. Occurs after a HTTP response is received
            /// </summary>
            void OnAfterResponse(HttpWebRequest request, HttpWebResponse response);

            
        #endregion
    }
}
